package com.ddl.controller;

import com.ddl.common.exception.ResultModel;
import com.ddl.service.ADService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

/**
 * @author: liyuxiang
 * @create: 2018-12-11
 */
@RestController
@RequestMapping(value = "/app/ad")
public class ADController {


    @Autowired
    ADService adService;

    @CrossOrigin(origins = "*", maxAge = 3600)
    @RequestMapping(value = "/getADInfo")
    public ResultModel getADInfo() {
        return adService.getAD();
    }

    @CrossOrigin(origins = "*", maxAge = 3600)
    @RequestMapping(value = "/getADDetail")
    public ResultModel getADDetail(@RequestBody Map<String, Object> map) {
        int adId = Integer.parseInt(map.get("id").toString());
        return adService.getADDetail(adId);
    }

}
